package com.cy.pj.module.controller;

import com.cy.pj.module.pojo.RequestParameter;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.Map;

@RestController
public class ParamObjectController {
    @RequestMapping("/doHandleRequestParam02")
    public String doHandleRequestParam02(String name, @DateTimeFormat(pattern="yyyy-MM-dd") @RequestParam Date startDate){
        return "request params "+name+"/startDate"+startDate;
    }
    @RequestMapping("/doHandleRequestParam03/{id}/{code}")
    public String doHandleRequestParam03(@PathVariable Integer id,@PathVariable Integer code){
        return "request params id="+id+"code="+code;
}

    @RequestMapping("/doHandleRequestParam04")
    public String doHandleRequestParam04(RequestParameter pojo){//pojo对象接收请求参数,pojo对象中需提供与参数名相匹配的set方法
        return "request params "+pojo.toString();
    }
    @RequestMapping("/doHandleRequestParam05/{name}/{startDate}")
    public String doHandleRequestParam05(RequestParameter pojo) {
        return "request params" + pojo.toString();
    }
    @RequestMapping("/doHandleRequestParam06")
    public String doHandleRequestParam06(@RequestParam Map<String,Object> map){
        return "request params "+map.toString();
    }
    @RequestMapping("/doHandleRequestParam07/{name}/{starDate}")
    public String doHandleRequestParam07(@PathVariable Map<String,Object> map){
        return "request params "+map.toString();
    }
}
